#ifndef NETWORKMANAGER_H
#define NETWORKMANAGER_H

#include <QObject>
#include <QTcpSocket>

class NetworkManager : public QObject
{
    Q_OBJECT
public:
    explicit NetworkManager(QObject *parent = nullptr);
    ~NetworkManager();

    void connectToServer(const QString &host, quint16 port);//连接服务器
    void sendCommand(const QByteArray &command, int len);//发送指令头
    void sendData(const QByteArray &data);//发送数据

signals:
    void dataReceived(const QByteArray &data);//接收到数据的信号

private slots:
    void onReadyRead();//读取数据，发送信号

private:
    QTcpSocket *socket;
};

#endif // NETWORKMANAGER_H
